﻿/*

========================================================================

	                        Light Prepass Renderer

		                        by Floris Groen

                         E-mail : fmfgroen@yahoo.com
                     Blog : www.florisgroen.blogspot.com
		      

========================================================================

*/

using System.Collections.Generic;
using LightPrePassRenderer.Engine.Interfaces;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace LightPrePassRenderer.Engine
{
    public class Light
    {
        public Color Color
        {
            get;
            set;
        }

        public float Intensity
        {
            get;
            set;
        }
    }

    public class DirectionalLight : Light
    {
        public Vector3 Direction
        {
            get;
            set;
        }
    }

    public class PointLight : Light
    {
        public Vector3 Position
        {
            get;
            set;
        }

        public float Radius
        {
            get;
            set;
        }
    }

    /// <summary>
    /// Simple manager that contains all lights. Has lists for point and directional lights.
    /// </summary>
    public class LightManager : ILightManager
    {
        List<DirectionalLight> directionalLights = new List<DirectionalLight>();
        List<PointLight> pointLights = new List<PointLight>();

        public DirectionalLight CreateDirectionalLight(Color color, float intensity, Vector3 direction)
        {
            var directionalLight = new DirectionalLight
            {
                Color = color,
                Intensity = intensity,
                Direction = direction
            };

            directionalLights.Add(directionalLight);

            return directionalLight;
        }

        public PointLight CreatePointLight(Color color, float intensity, Vector3 position, float radius)
        {
            var pointLight = new PointLight
            {
                Color = color,
                Intensity = intensity,
                Position = position,
                Radius = radius
            };
            
            pointLights.Add(pointLight);

            return pointLight;
        }

        public int DirectionalLightCount
        {
            get { return directionalLights.Count; }
        }

        public int PointLightCount
        {
            get { return pointLights.Count; }
        }

        public DirectionalLight GetDirectionalLight(int index)
        {
            return directionalLights[index];
        }

        public PointLight GetPointLight(int index)
        {
            return pointLights[index];
        }
    }
}
